﻿@page "{categoryId?}"

@inject ContentService _contentService
@{
    var categoryId = ViewContext.RouteData.Values["categoryId"].To<int?>(null);
    Channels channel = Channels.Content;
    if (ViewContext.HttpContext.Request.Query["channel"].Any())
    {
        channel = (Enum.Parse<Channels>(ViewContext.HttpContext.Request.Query["channel"].ToString(), true));

    }
    if (categoryId.HasValue)
    {
        var category = await _contentService.GetCategoryAsync(categoryId.Value);
        ViewBag.Title = $"{category?.Name}";
    }
}

@await Component.InvokeAsync($"ContentIndex{channel}",new { categoryId })
